package se.joakimback.decorator.view;

import java.awt.BorderLayout;
import java.awt.Panel;

import javax.swing.JFrame;

import se.joakimback.decorator.renderer.Renderer;

public class MainWindow {
	public MainWindow(String pTitle) {
		Workspace vWorkspace = Workspace.getSingleton();
		
		ResultView vResultView = new ResultView();
		LayerConfiguration vConfiguration = new LayerConfiguration();
		vWorkspace.addListener(vConfiguration);
		
		ProgressBar vProgressBar = new ProgressBar();
		Renderer.getSingleton().addProgressListener(vProgressBar);
		
		Panel vViewPanel = new Panel(new BorderLayout());
		vViewPanel.add(vResultView, BorderLayout.CENTER);
		vViewPanel.add(vProgressBar, BorderLayout.SOUTH);
		
		Panel vContents = new Panel(new BorderLayout());
		vContents.add(vViewPanel, BorderLayout.CENTER);
		vContents.add(vConfiguration, BorderLayout.EAST);
		
		JFrame vFrame = new JFrame(pTitle);
		vFrame.getContentPane().add(vContents);
		vFrame.pack();
		vFrame.setVisible(true);
		vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
